﻿using System;
using System.Data;
using System.Data.SqlClient;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using BaseData;
using BaseData.Common;

namespace TaxData.Tax
{
    /// <summary>
    /// 综合查询数据层
    /// </summary>
    public class ZongheQueryData
    {
        /// <summary>
        /// 综合查询列表
        /// </summary>
        public static DataTable GetList(string strWhere, int pageSize, int page, ref int allCount)
        {
            DataTable dt = new DataTable();
            string condition = " where 1=1" + strWhere;
            string sqlCount = "select count(1) from v_TaxZongheQuery with(nolock) " + condition;
            allCount = (int)DataConfig.GetSingle(BusinessType.DBRead, sqlCount);
            if (allCount > 0)
            {
                int startNum = (page - 1) * pageSize + 1;
                int endNum = page * pageSize;
                string sqlInner = "select *,ROW_NUMBER() over(order by DepartmentName desc,Name) as RowNumber from v_TaxZongheQuery a with(nolock) " + condition;
                string sqlUserList = string.Format("SELECT * FROM ({0}) T WHERE T.RowNumber BETWEEN {1} AND {2} order by RowNumber asc", sqlInner, startNum, endNum);
                dt = DataConfig.QueryRecords(BusinessType.DBRead, sqlUserList);
            }
            return dt;
        }
    }
}
